<?php

namespace App\Providers;

use App\Models\Ogz;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    protected $id;
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot(Request $request)
    {
        $this->pid =$request->pid ?  $request->pid :1;
        $this->id =$request->id ?  $request->id :1;
        view()->composer('backend/common/rightnav', function ($view) {
            $pid = $this->pid ? $this->pid : (auth()->user()->ogzs[0]->id ? auth()->user()->ogzs[0]->id: 1 );
            $id = $this->id;
            $pinfo = Ogz::find($pid);
            $info = Ogz::find($id);
            $parentInfo = '';
            if($pinfo){
                $parentInfo = Ogz::find($pinfo->pid) ? Ogz::find($pinfo->pid) : $pinfo ;
            }
//            dd($info);
            $view->with('parentinfo',$parentInfo)->with('info',$info);
        });
        //
        $this->app['request']->server->set('HTTPS', $this->app->environment() != 'local');
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
